<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta content="yes" name="apple-mobile-web-app-capable">
  <meta content="yes" name="apple-touch-fullscreen">
  <meta content="telephone=no,email=no" name="format-detection">
  <script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
  <title>返利不停步</title>
  <link rel="stylesheet" href="./index.css">
</head>
<body>
  <div class="head-img">
    <img id="head-img" width="100%">
  </div>
  <p class="name"><span id="nickname"></span></p>
  <p class="id">ID:<span id="uid"></span></p>
  <p class="diamond-desc">当前账户可享奖励已达</p>
  <p class="diamond"><span id="diamond"></span>钻</p>
  <div class="btn" onclick="toOpen()">立享奖励</div>

  <div class="dialog">
    <p>提示</p>
    <p>您可前往声撩公众号进行兑换</p>
    <div onclick="hideDialog('dialog')">知道了</div>
  </div>
  <!-- 遮罩层 -->
  <div class="overlay" onclick="hideDialog('dialog')"></div>
  <!-- end -->
</body>
<script src="./lib.js"></script>
<script>
  // const baseUrl = "http://lyj.ztaudio-activity.com";
  // var baseUrl = "https://ztaudio-api.whzcth.com:8866"
  var baseUrl = "http://ztaudio-activity.kekestar.cn"
  // var baseUrl = "http://47.103.212.118:5084"
  let overlay = document.getElementsByClassName('overlay')[0];


  // 用户信息
  let userInfo = {
    user_id: 0,
    nickname: null,
    head_img: '',
    kk_balance: 0
  }

  var $_GET = (function(){
        var url = window.document.location.href.toString();
        var u = url.split("?");
        if(typeof(u[1]) == "string"){
            u = u[1].split("&");
            var get = {};
            for(var i in u){
                var j = u[i].split("=");
                get[j[0]] = j[1];
            }
            return get;
        } else {
            return {};
        }
    })();
  // getImgCode()
  getUserInfo();
  function getUserInfo() {
    ajaxGet(baseUrl + "/invite/user_info", { user_id: $_GET['user_id'] }, function(req) {
      if(req.code == 0) {
        userInfo.kk_balance = req.data.kk_balance / 100

        document.getElementById('nickname').textContent = req.data.nickname
        document.getElementById('uid').textContent = req.data.uuid
        document.getElementById('diamond').textContent = Number(req.data.kk_balance / 10 * 0.015).toFixed(0)
        document.getElementById('head-img').setAttribute('src', req.data.head_img)

      }
    }, function(err) {

    })
  }
  function openDialog(id) {
    var obj = document.getElementsByClassName(id)[0];
    obj.style.visibility = "visible";
    overlay.style.visibility = "visible";

    setTimeout(() => {
      hideDialog('dialog')
    }, 3000);
  }

  function hideDialog(id) {
    var obj = document.getElementsByClassName(id)[0]
      obj.style.visibility = "hidden";
      overlay.style.visibility = "hidden";
  }

  function isIOS() {
    return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  }
  function isAndroid () {
    return navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Linux') > -1;
  }
  function toOpen(){
    if (isAndroid()) {
      keke.exchangeOnClick();
    } else if (isIOS()) {
      openDialog('dialog')
    }
  }

</script>
</html>
